package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sRepairInfoDetail;
import com.ruoyi.system.service.car4s_service.ICar4sRepairInfoDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修信息明细单Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_repair_info_detail")
public class Car4sRepairInfoDetailController extends BaseController
{
    @Autowired
    private ICar4sRepairInfoDetailService car4sRepairInfoDetailService;

    /**
     * 查询维修信息明细单列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sRepairInfoDetail car4sRepairInfoDetail)
    {
        startPage();
        List<Car4sRepairInfoDetail> list = car4sRepairInfoDetailService.selectCar4sRepairInfoDetailList(car4sRepairInfoDetail);
        return getDataTable(list);
    }

    /**
     * 导出维修信息明细单列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:export')")
    @Log(title = "维修信息明细单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sRepairInfoDetail car4sRepairInfoDetail)
    {
        List<Car4sRepairInfoDetail> list = car4sRepairInfoDetailService.selectCar4sRepairInfoDetailList(car4sRepairInfoDetail);
        ExcelUtil<Car4sRepairInfoDetail> util = new ExcelUtil<Car4sRepairInfoDetail>(Car4sRepairInfoDetail.class);
        util.exportExcel(response, list, "维修信息明细单数据");
    }

    /**
     * 获取维修信息明细单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:query')")
    @GetMapping(value = "/{repairDetailId}")
    public AjaxResult getInfo(@PathVariable("repairDetailId") Long repairDetailId)
    {
        return success(car4sRepairInfoDetailService.selectCar4sRepairInfoDetailByRepairDetailId(repairDetailId));
    }

    /**
     * 新增维修信息明细单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:add')")
    @Log(title = "维修信息明细单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sRepairInfoDetail car4sRepairInfoDetail)
    {
        return toAjax(car4sRepairInfoDetailService.insertCar4sRepairInfoDetail(car4sRepairInfoDetail));
    }

    /**
     * 修改维修信息明细单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:edit')")
    @Log(title = "维修信息明细单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sRepairInfoDetail car4sRepairInfoDetail)
    {
        return toAjax(car4sRepairInfoDetailService.updateCar4sRepairInfoDetail(car4sRepairInfoDetail));
    }

    /**
     * 删除维修信息明细单
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_repair_info_detail:remove')")
    @Log(title = "维修信息明细单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairDetailIds}")
    public AjaxResult remove(@PathVariable Long[] repairDetailIds)
    {
        return toAjax(car4sRepairInfoDetailService.deleteCar4sRepairInfoDetailByRepairDetailIds(repairDetailIds));
    }
}
